package vip.websky.project.web;

import com.alibaba.fastjson.JSON;
import lombok.Data;
import vip.websky.project.module.enums.ChannelEnum;

import java.io.Serializable;

/**
 * @Author Yong.Yang E-mail:yang2048@qq.com
 * @Create 2017/8/27-17:42
 **/
@Data
public class GetRequestDTO<T> implements Serializable {

    private String channel;
    private String version = "1.0.0";
    private String interCode;
    private String traceToken;//请求 token
    private String param; //json 字符串

    public static <T> GetRequestDTO getRequestDTO(ChannelEnum channel, String interCode, T t) {
        GetRequestDTO requestDTO = new GetRequestDTO();
        requestDTO.setChannel(channel.name());
        requestDTO.setInterCode(interCode);
        requestDTO.setParam(JSON.toJSONString(t));
        return requestDTO;
    }
}
